package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.SignUpRoom;
import com.eling.elcms.travel.service.ISignUpRoomManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Controller
public class SignUpRoomController extends BaseFormController{
	@Autowired
	private ISignUpRoomManager signUpRoomManager;
	
	@RequestMapping("/api/signuproom/save")
    @ResponseBody
	public SignUpRoom save(@ModelAttribute@ModelFilling SignUpRoom signUp){
		return signUpRoomManager.save(signUp);
	}
	
	@RequestMapping("/api/signuproom/query")
    @ResponseBody
	public List<SignUpRoom> query(@ModelAttribute SignUpRoom signUp){
		return signUpRoomManager.query(signUp);
	}
	
	@RequestMapping("/api/signuproom/search*")
	@ResponseBody
	public List<SignUpRoom> search(@ModelAttribute SearchCondition sc,@ModelAttribute SignUpRoom signUp){
		sc.setQueryCondition(signUp);
		return signUpRoomManager.search(sc);
	}
	
	@RequestMapping("/api/signuproom/{pkSignUpRoom}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkSignUpRoom){
		signUpRoomManager.remove(pkSignUpRoom);
		return new Msg("删除成功");
	}
	
	/**
	 * 查询散客房型登记
	 * @param pkNonMemGroupReserve
	 * @return
	 * @author zhoulin
	 */
	@RequestMapping("/api/signuproom/querybyreserve")
    @ResponseBody
	public List<SignUpRoom> queryByReserve(@RequestParam(name = "pkNonMemGroupReserve") Long pkNonMemGroupReserve){
		return signUpRoomManager.queryByReserve(pkNonMemGroupReserve);
	}
	
	/**
	 * 落实散客房间配置
	 * @param pkNonMemGroupReserve
	 * @param pkSignUpRoom
	 * @return
	 * @author zhoulin
	 */
	@RequestMapping("/api/signuproom/updatestatus")
    @ResponseBody
	public SignUpRoom updateStatus(@RequestParam(name = "pkNonMemGroupReserve") Long pkNonMemGroupReserve,
			@RequestParam(name = "pkSignUpRoom", required = false) Long pkSignUpRoom){
		return signUpRoomManager.updateStatus(pkNonMemGroupReserve, pkSignUpRoom);
	}
	
}
